package com.unlcn.erp.hyc.interfaces.api.schedule;

import com.unlcn.erp.hyc.interfaces.backend.service.CallWayBillByHYCService;
import org.joda.time.DateTime;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

/**
 * Created by zhiche024 on 2017/9/19.
 */
public class CallWayBillByHYCPort implements Job{

    private static final Logger LOGGER = LoggerFactory.getLogger(CallWayBillByHYCPort.class);

    @Autowired
    private CallWayBillByHYCService callWayBillByHYCService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        LOGGER.info("CallWayBillByHYCPort job startTime {}", DateTime.now().toString("yyyy-MM-dd HH:mm:ss.SSS"));
        try{
            callWayBillByHYCService.getWayBillCodes();
        }catch(Exception e){
            e.printStackTrace();
            LOGGER.error("CallWayBillByHYCPort 定时任务保存出错 error: {}", e);
        }
        LOGGER.info("CallWayBillByHYCPort job endTime {}", DateTime.now().toString("yyyy-MM-dd HH:mm:ss.SSS"));

    }
}
